package com.example.wangning.mycarofcountry.recommend.newest;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.mycarofcountry.entity.dao.Recommend_Focusing;

import java.util.List;

/**
 * Created by dllo on 16/1/7.
 */
public class ViewPagerAdapter extends FragmentPagerAdapter{
    private List<Recommend_Focusing> data;
    private int positions;
    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }
    public void addData(List<Recommend_Focusing> datas){
        data = datas;
        notifyDataSetChanged();
    }
    @Override
    public Fragment getItem(int position) {
        positions = position;
        Recommend_Focusing focusimg = data.get(position % data.size());
        String imgurl = focusimg.getImgurl();
        return FocusimgFragment.getInstance(imgurl);
    }
    @Override
    public int getCount() {
        return data != null ? Integer.MAX_VALUE : 0;
    }
}
